package com.junqson.je.common.exception;

import com.junqson.je.common.model.ResultEnum;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * @Descriptions
 * @Company
 * @Author Junqson
 * @Date 2020/1/20 23:33
 * @Version 1.0
 */
@Slf4j
public class BizException extends RuntimeException {
    @Getter
    private Integer code;

    public BizException(ResultEnum resultEnum) {
        super(resultEnum.getMsg());
        this.code = resultEnum.getCode();

        log.warn("exception! {}", resultEnum.getMsg());
    }

    public BizException(Integer code,  String msg) {
        super(msg);
        this.code = code;
        log.warn("exception! {}", msg);
    }

    public BizException(String msg) {
        super(msg);
        this.code = 1;

        log.warn("exception! {}", msg);
    }

}
